﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class ChucNang_KhachHangDaiChung_KhacHangDaiChung_XemThongTinCaNhan : System.Web.UI.Page
{
    string CMND = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["CMND"] == null)
        {
            Response.Redirect("~/index.aspx");
        }
        CMND = Request["CMND"];
        GlobalFunctions gf = new GlobalFunctions();
        if (gf.getCMND().Trim() != CMND)
            Response.Write("<script>alert('Vui lòng đăng nhập!');location.href='/SMO/ChucNang/NguoiDung/NguoiDung_DangNhap.aspx'</script>");

        DataDSTableAdapters.TAIKHOANTableAdapter tkadapter = new DataDSTableAdapters.TAIKHOANTableAdapter();
        DataDS.TAIKHOANDataTable tktable = tkadapter.TAIKHOAN_LayTheoCMND(CMND);

        lblCMND.Text = CMND;
        lblDiaChi.Text = (string)tktable.Rows[0]["DiaChi"];
        lblDienThoai.Text = tktable.Rows[0]["DienThoai"].ToString();
        lblEmail.Text = tktable.Rows[0]["Email"].ToString();
        lblHoTen.Text = tktable.Rows[0]["HoTen"].ToString();

        if ((bool)tktable.Rows[0]["Is_Mail_SP_YeuThich"] == true)
            lbIsSendMail.Text = "Gửi mail thông báo sản phẩm yêu thích: BẬT";
        else
            lbIsSendMail.Text = "Gửi mail thông báo sản phẩm yêu thích: TẮT";
        
        switch (tktable.Rows[0]["Role"].ToString())
        {
            case "1":
                lblVaiTro.Text = "Admin";
                break;
            case "2":
                lblVaiTro.Text = "Khách hàng thân thiết";
                break;
            case "3":
                lblVaiTro.Text = "Khách hàng đại chúng";
                break;
        }
        Image1.ImageUrl = tktable.Rows[0]["Avatar"].ToString();

    }
    protected void btnThem_Click(object sender, EventArgs e)
    {
        Response.Redirect("KHDC_CapNhatThongTinCaNhan.aspx?CMND=" + CMND);

    }
}
